package com.faintlight.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 显式映射 /static/** 到 classpath:/static/ 和 file:./src/main/resources/static/
        registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/static/", "file:./src/main/resources/static/")
                .setCachePeriod(3600);  // 缓存1小时
    }
}